﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SeaBattle.Domain.Entities;

namespace SeaBattle.UI.Web.Models
{
    public class GameBoardSetupModel
    {
        public Player User { get; set; }
        public Game Game { get; set; }
        public string CellClass(int x, int y)
        {
            switch (Field.AField[x,y])
            {
                case FieldType.TYPEACSESS:
                    return "acsess";
                case FieldType.TYPENOACSESS:
                    return "noacsess";
                case FieldType.TYPECLOSEDACSESS:
                    return "closedacsess";
                case FieldType.TYPENONE:
                    return "none";
            }
            return "ship";
        }
        public bool IsSetuped
        {
            get
            {
                if (Game.BoardStates[User] == BoardSetupState.STATEEND)
                    return true;
                return false;
            }
        }
        public Field Field { get { return Game.realField[User]; } }
        public int Step
        {
            get
            {
                return Game.stepMakingSheep[User];
            }
            set
            {
                Game.stepMakingSheep[User] = value;
            }
        }
        public int Count { get; set; }
        public string StatusSetuping
        {
            get
            {
                const string ship1 = "submarine";
                const string ship2 = "destroyer";
                const string ship3 = "cruiser";
                const string ship4 = "linkorn";

                string str= "";
                switch (Game.BoardStates[User])
                {
                    case BoardSetupState.STATEONE1:
                        str = "Please put " + ship1;
                        Count = 4;
                        break;
                    case BoardSetupState.STATEONE2:
                        str = "Please put " + ship1;
                        Count = 3;
                        break;
                    case BoardSetupState.STATEONE3:
                        str = "Please put " + ship1;
                        Count = 2;
                        break;
                    case BoardSetupState.STATEONE4:
                        str = "Please put " + ship1;
                        Count = 1;
                        break;
                    case BoardSetupState.STATETWO1:
                        str = "Please put " + ship2;
                        Count = 3;
                        break;
                    case BoardSetupState.STATETWO2:
                        str = "Please put " + ship2;
                        Count = 2;
                        break;
                    case BoardSetupState.STATETWO3:
                        str = "Please put " + ship2;
                        Count = 1;
                        break;
                    case BoardSetupState.STATETHREE1:
                        str = "Please put " + ship3;
                        Count = 2;
                        break;
                    case BoardSetupState.STATETHREE2:
                        str = "Please put " + ship3;
                        Count = 1;
                        break;
                    case BoardSetupState.STATEFOUR1:
                        str = "Please put " + ship4;
                        Count = 1;
                        break;
                    case BoardSetupState.STATEEND:
                        str = "Wait your opponent";
                        Count = 0;
                        break;
                }
                return str;
            }
        }
        //public int i { get; set; }
        //public int j { get; set; }

        //public FieldType Acsess { get{return FieldType.TYPEACSESS; }}
        //public FieldType NoAcsess { get { return FieldType.TYPEACSESS; } }
        //public FieldType ClosedAcsess { get { return FieldType.TYPEACSESS; } }
        //public FieldType None { get { return FieldType.TYPEACSESS; } }

    }
}